package com.mz.ozy.mvp.presenter;

import android.app.Activity;
import android.content.Context;

import com.mz.ozy.base.BasePresenterImpl;
import com.mz.ozy.bean.PopularBean;
import com.mz.ozy.mvp.model.ShogModel;
import com.mz.ozy.mvp.view.PopularContract;
import com.mz.ozy.net.MyObserver;
import com.mz.ozy.utils.RxUtil;

import okhttp3.ResponseBody;

/**
 * @author lifeStyle on 2020/4/26 0026.
 */
public class PopularPresenter extends BasePresenterImpl<PopularContract.View> implements PopularContract.Presenter{
    private ShogModel shogModel;

    public PopularPresenter() {
        super();
        shogModel = new ShogModel();
    }


    @Override
    public void getInfo(Activity activity, String page) {
        shogModel.getPopInfo(activity,page).
                compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<PopularBean>(mView, false) {
                    @Override
                    public void onSuccesss(PopularBean homeMerBean) {
                        mView.getInfo(homeMerBean);

                    }
                });
    }


    @Override
    public void getInfoDetailSuccess(Context context,String id, String irst) {
        shogModel.getPopDetailInfo(context,id,irst).
                compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<PopularBean>(mView, false) {
                    @Override
                    public void onSuccesss(PopularBean homeMerBean) {
                        mView.getInfoDetailSuccess(homeMerBean);

                    }
                });
    }
}
